﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace Royaume
{
    public partial class Sommaire : System.Web.UI.Page
    {
       // SqlDataReader dr;// = new SqlDataReader();
        SqlConnection cn;
        SqlCommand cmd;
        cSql objsql = new cSql("(local)", "DB_GAME", "RoyaumesLibres", "789456a");


        protected void Page_Load(object sender, EventArgs e)
        {
            this.cn = Connect.getconnectionstringG();

          this.afficherConstruction();
         // this.AfficheRessource();

        }

        private void afficherConstruction()
        {
            SqlDataReader dr;
            string tempsRequis;
            string tempsRestant;
            string Nombatiment;

            cn.Open();
            this.cmd = new SqlCommand();
            this.cmd.Connection = this.cn;

            this.cmd.CommandText = "spShowtempsRestant";
            this.cmd.CommandType = CommandType.StoredProcedure;
            this.cmd.Parameters.Clear();
            this.cmd.Parameters.Add("@FkMembre", SqlDbType.Int).Value = Session["pkUser"];
            
            dr = cmd.ExecuteReader();
            
            while (dr.Read())
            {
                tempsRequis = dr[2].ToString();
                tempsRestant = dr[3].ToString();
                Nombatiment = (string)dr[0];
                this.tempsConstruction.Text = "Pour la construction de votre " + Nombatiment + " il reste " + tempsRestant +  "heures sur " + tempsRequis+ " heure" ;

            }
         
            cn.Close();
        }

      //  private void AfficheRessource()
      //  {

      //     // SqlDataReader dr;
           
      //      cn.Open();
      //      this.cmd = new SqlCommand();
      //      this.cmd.Connection = this.cn;
      //      this.cmd.CommandText = "spCalculNourriture";
      //      this.cmd.CommandType = CommandType.StoredProcedure;
      //      this.cmd.Parameters.Clear();
      //      this.cmd.Parameters.Add("@FkMembre", SqlDbType.Int).Value = Session["pkUser"];

      //      int Nourriture = (int)cmd.ExecuteScalar();
      //      this.Label2.Text = Nourriture.ToString();
      ///*      dr = cmd.ExecuteReader();

      //      while (dr.Read())
      //      {
      //          Nourriture = (int)dr[0];
              
      //          this.Label2.Text = Nourriture.ToString();

      //      }     */
      //      cn.Close();

      //  }   

    }
}